﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace WebApplication1
{
    public class ConnectionSelect
    {
        public DataSet Select(string query)
        {
            SqlConnection sqlcon = new SqlConnection();
            sqlcon.ConnectionString = "Data Source=.\\SQLEXPRESS;Initial Catalog=NTest;Integrated Security=True";
            sqlcon.Open();

            SqlCommand sqlcomm = new SqlCommand();
            sqlcomm.Connection = sqlcon;

            sqlcomm.CommandText = query;
            sqlcomm.CommandType = CommandType.Text;

            DataSet ds = new DataSet();
         
            SqlDataAdapter sqlad = new SqlDataAdapter(sqlcomm);
            sqlad.Fill(ds);
            sqlcon.Close();
            return ds;
        }

        public void Insert(string query)
        {
            SqlConnection SqlCon = new SqlConnection();
            SqlCon.ConnectionString = "Data Source=.\\SQLEXPRESS;Initial Catalog=NTest;Integrated Security=True";
            SqlCon.Open();

            SqlCommand SqlCom = new SqlCommand();
            SqlCom.Connection = SqlCon;

            SqlCom.CommandText = query;
            SqlCom.CommandType = CommandType.Text;




            SqlCom.ExecuteNonQuery();
            
        }
    }
}